package thread;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @Description: null
 * @Project: testDemo
 * @Author: hjibo
 * @CreateDate: 2019/1/24 09:50
 * @ModificationHistory: （who whatTime doWhat）
 */
public class ThreadDemo3 implements Runnable {
    private Integer count = 0;
    private Lock lock = new ReentrantLock();

    @Override
    public void run() {
        Thread.currentThread().setName("ThreadDemo3线程");
        lock.lock();
        try {
            count++;
            System.out.println("线程："+Thread.currentThread().getName()+","+count);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            lock.unlock();
        }
    }
}
